from apps.admin import db


# 新建表Role
class Book(db.Model):
    __tablename__ = 'fa_book' #表名
    id = db.Column(db.Integer, primary_key = True) # id字段, int 类型,主键
    rank = db.Column(db.Integer) # 
    title = db.Column(db.String(64), unique = True) # name字段, 字符串类型,唯一
    author = db.Column(db.String(64)) # 
    country = db.Column(db.String(64)) # 
    score = db.Column(db.String(64)) # 
    desc = db.Column(db.String(255)) # 
    link = db.Column(db.String(255)) # 
    see_status = db.Column(db.Integer) # 
    createtime = db.Column(db.Integer) # 
    updatetime = db.Column(db.Integer) # 
    # users = db.relationship('User', backref = 'role', lazy = 'joined') # 外键关系
    
    def __init__(self, rank, title, author, score, link, desc, country, see_status):
        # self.id = id
        self.rank = rank
        self.title = title
        self.author = author
        self.score = score
        self.link = link
        self.desc = desc
        self.country = country
        self.see_status = see_status

    def __repr__(self): # 相当于toString
        return '<Book %r>' % self.title